package org.dwpd.controller.user;

import org.dwpd.domain.common.Result;
import org.dwpd.service.user.IFollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/follow")
@RestController
public class FollowController {

    @Autowired
    private IFollowService followService;

    /**
     * 关注用户 || 取关用户
     * @param followUserId 关注对象ID
     * @param isFollow // true: 关注  false: 取关
     */
    @PostMapping("/{id}/{isFollow}")
    public Result follow(@PathVariable("id") Integer followUserId, @PathVariable("isFollow") boolean isFollow) {
        return followService.follow(followUserId, isFollow);
    }

    /**
     * 判断用户是否被当前用户关注
     * @param followUserId 关注对象ID
     */
    @GetMapping("/isFollow/{id}")
    public Result isFollow(@PathVariable("id") Integer followUserId) {
        return followService.isFollow(followUserId);
    }

    /**
     * 获取与指定用户的共同关注
     * @param id 指定用户ID
     */
    @GetMapping("/common/{id}")
    public Result followCommons(@PathVariable("id") Integer id) {
        return followService.followCommons(id);
    }

    /**
     * 获取当前用户的粉丝信息
     */
    @GetMapping("/fans")
    public Result fans() {
        return followService.fans(null);
    }

    /**
     * 获取当前用户的关注对象信息
     */
    @GetMapping("/follows")
    public Result follows() {
        return followService.follows(null);
    }

    /**
     * 获取指定用户的粉丝信息
     */
    @GetMapping("/getFansByUserId/{id}")
    public Result getFansByUserId(@PathVariable("id") Integer id) {
        return followService.fans(id);
    }

    /**
     * 获取指定用户的关注信息
     */
    @GetMapping("/getFollowsByUserId/{id}")
    public Result getFollowsByUserId(@PathVariable("id") Integer id) {
        return followService.follows(id);
    }
}
